import java.util.Scanner;
 
public class Main{

    public static void main(String[] args){
    	
    	int N, K, i, loc;
    	
        Scanner sc=new Scanner(System.in);
        String c = sc.nextLine();
        
        N = Integer.parseInt(c);
        String[] str = new String[N];
        for( i=0;i<N;i++ ){
        	str[i] = sc.nextLine();
        }
        K = sc.nextInt();
        for( i=0;i<K;i++ ) {
        	loc = sc.nextInt();
        	if(loc<N&&loc>=0) {
        		String[] tmp = str[loc].split(" ");  // 0 3 4 2 1
        		System.out.println(tmp[0]+" "+tmp[3]+" "+tmp[4]+" "+tmp[2]+" "+tmp[1]);
        	} else {
        		System.out.println("Not Found");
        	}
        }

    }
    
}
